package com.zoe.app.controller;

import cn.hutool.core.date.DateUtil;
import com.zoe.app.anno.AutoIdempotent;
import com.zoe.app.config.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Zoe.Zhang
 * @date 2021/10/24
 * @description
 */
@RestController
public class HelloController {
    @Autowired
    private TokenService tokenService;

    @GetMapping("/hello")
    public String hello() {
        return "if you see this page,your app is running   " + DateUtil.formatChineseDate(DateUtil.date(), false, true);
    }

    @GetMapping("/getToken")
    public String getToken() {
        String token = tokenService.createToken();
        return token;
    }

    @PostMapping("/add")
    @AutoIdempotent(enable = true)
    public String add() {
        return DateUtil.date() + "  add";
    }

    @AutoIdempotent
    @PostMapping("/add2")
    public String add2() {
        return DateUtil.date() + "  add2";
    }
}
